﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Effector.Data
{
    /// <summary>
    /// Working with projects.
    /// </summary>
    public class Project
    {
        #region Private Fields

        // name of the project
        private string _projectName;

        // the filename of the project.same as the project name
        private string _projectFileName;

        private string _projectFileExt = ".efproj";

        //the path of the project
        private string _projectPath;

        //needs to be saved
        private bool _isDirty = false;

        //list of children
        private List<BaseProjectItem> _children;

        #endregion

        #region Public

        #region Construction

        /// <summary>
        /// Initializes a new instance of the <see cref="Project"/> class.
        /// </summary>
        public Project()
        {
            _projectName = "Project1";
            _projectFileName = _projectName + _projectFileExt;
            _projectPath = Directory.GetCurrentDirectory();
            _children = new List<BaseProjectItem>();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Project"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public Project(string name)
        {
            _projectName = name;
            _projectFileName = _projectName + _projectFileExt;
            _projectPath = Directory.GetCurrentDirectory();
            _children = new List<BaseProjectItem>();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Project"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="path">The path.</param>
        public Project(string name, string path)
        {
            _projectName = name;
            _projectFileName = _projectName + _projectFileExt;
            _projectPath = path;
            _children = new List<BaseProjectItem>();
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets the name of the project.
        /// </summary>
        /// <value>The name of the project.</value>
        public string ProjectName
        {
            get { return _projectName; }
        }

        /// <summary>
        /// Gets the project file.
        /// </summary>
        /// <value>The project file.</value>
        public string ProjectFile
        {
            get { return _projectFileName; }
        }

        /// <summary>
        /// Gets the project path.
        /// </summary>
        /// <value>The project path.</value>
        public string ProjectPath
        {
            get { return _projectPath; }
        }

        /// <summary>
        /// Gets the project file ext.
        /// </summary>
        /// <value>The project file ext.</value>
        public string ProjectFileExt
        {
            get { return _projectFileExt; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is dirty.
        /// </summary>
        /// <value><c>true</c> if this instance is dirty; otherwise, <c>false</c>.</value>
        public bool IsDirty
        {
            get { return _isDirty; }
            set { _isDirty = value; }
        }

        /// <summary>
        /// Gets the children.
        /// </summary>
        /// <value>The children.</value>
        public List<BaseProjectItem> Children
        {
            get { return _children; }
        }

        #endregion

        #endregion
    }
}
